Skip to content

feat: add relationships to ConfigMaps, Secrets, PV, PVC, SA, StorageClass and ImagePullSecrets#146

Merged
steveteuber merged 5 commits into
steveteuber:mainfrom
RyszardSzwajlik:cm-and-secret-pod-relationship
Mar 24, 2026
Merged

feat: add relationships to ConfigMaps, Secrets, PV, PVC, SA, StorageClass and ImagePullSecrets#146
steveteuber merged 5 commits into
steveteuber:mainfrom
RyszardSzwajlik:cm-and-secret-pod-relationship

Conversation

@RyszardSzwajlik

@RyszardSzwajlik RyszardSzwajlik commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

This PR, prepared as part of the work done by the AI R&D team at J‑Labs, improves dependency resolution in kubectl graph by adding several missing relationships between workloads, configuration objects, and storage resources.

The main fix is for pod configuration dependencies. kubectl graph now adds Pod -> ConfigMap relationships for:

  • spec.volumes[].configMap.name
  • spec.volumes[].projected.sources[].configMap.name
  • envFrom[].configMapRef.name
  • env[].valueFrom.configMapKeyRef.name

It also adds the analogous Pod -> Secret relationships for:

  • spec.volumes[].secret.secretName
  • spec.volumes[].projected.sources[].secret.name
  • envFrom[].secretRef.name
  • env[].valueFrom.secretKeyRef.name

In addition, pod identity and registry-related dependencies are now included:

  • Pod -> ServiceAccount via spec.serviceAccountName
  • Pod -> Secret with the ImagePullSecret edge label via spec.imagePullSecrets[].name

Storage relationships were extended as well:

  • Pod -> PersistentVolumeClaim via spec.volumes[].persistentVolumeClaim.claimName
  • PersistentVolumeClaim -> PersistentVolume via spec.volumeName
  • PersistentVolume -> StorageClass via spec.storageClassName
  • PersistentVolumeClaim -> StorageClass via spec.storageClassName

To make these references reliable, graph construction now pre-registers all requested resources as nodes before running resource-specific relationship analysis. This removes input-order sensitivity, so references resolve correctly even when the referenced objects appear later in the requested resource list.
When a referenced resource already exists in the graph, relationships point to the real node and preserve metadata such as labels and annotations. Otherwise, a minimal fallback node is created from kind, namespace, and name.

@RyszardSzwajlik RyszardSzwajlik changed the title fix: add pod relationships to ConfigMaps and Secrets feat: add relationships to ConfigMaps, Secrets, PV, PVC, SA, StorageClass and ImagePullSecrets Mar 23, 2026
@steveteuber

Copy link
Copy Markdown
Owner

Looks good to me. Thanks!

@steveteuber steveteuber merged commit 1436d57 into steveteuber:main Mar 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants